package com.webcat.entity;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.webcat.enums.ResultEnum;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

/**
 * @author wangjun
 * @date 18-2-9 下午6:09
 * @description
 * @modified by
 */

@Data
@Slf4j
public class AiResponse<T> extends Response<T> {
    private String chatId;
    public static<T> AiResponse<T> success(String chatId, T data) {
        AiResponse<T> response = new AiResponse<>();
        response.setServerTime(new Date());
        response.setCode(ResultEnum.SUCCESS.getCode());
        response.setMsg(ResultEnum.SUCCESS.getMsg());
        response.setData(data);
        if (chatId != null && !chatId.isEmpty()) {
            response.setChatId(chatId);
        }
        log.info(JSONObject.toJSONString(response));
        return response;
    }
    public static<T> AiResponse<T> success(String chatId) {
        AiResponse<T> response = new AiResponse<>();
        response.setServerTime(new Date());
        response.setCode(ResultEnum.SUCCESS.getCode());
        response.setMsg(ResultEnum.SUCCESS.getMsg());
        response.setChatId(chatId);
        log.info(JSONObject.toJSONString(response));
        return response;
    }
}
